package com.graduation.roombooking.controller.applet;

import com.graduation.roombooking.service.UserService;
import com.graduation.roombooking.vo.RegisterVo;
import com.graduation.roombooking.vo.RespBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author:CaiShuangLian
 * @FileName:
 * @Date:Created in  2022/5/5 15:47
 * @Version:
 * @Description:TODO
 */
@RestController
@Api(tags = "Applet——用户模块")
@RequestMapping("/applet/user")
public class AppletUserController {
    @Autowired
    private UserService userService;

    @ResponseBody
    @ApiOperation("用户注册")
    @PostMapping("/register")
    @Transactional(rollbackFor = Exception.class)
    public RespBean registerUser(@Valid @RequestBody RegisterVo registerVo){
        return userService.register(registerVo);
    }

    @ApiOperation("发送验证码")
    @PostMapping("/sendEmail")
    @ResponseBody
    public RespBean sendEmail(@Valid @RequestParam(name="email") String email){
        return userService.sendEmail(email);
    }


}
